package com.sayice.coursetable.ui.course.day;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.sayice.coursetable.logic.Repository;
import com.sayice.coursetable.logic.model.Course;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class DayViewModel extends ViewModel {
    public final List<Course> courses = new ArrayList<>();

    private final MutableLiveData<List<Course>> courseLiveData = new MutableLiveData<>();

    public LiveData<List<Course>> getCourseLiveData() {
        return courseLiveData;
    }

    /**
     * 更新课程
     *
     * @param tableId 课表编号
     */
    public void updateCourses(int tableId) {
        new Thread(() -> {
            courseLiveData.postValue(Repository.getDayCourses(tableId));
        }).start();
    }
}
